package com.example.demo.Entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.CreationTimestamp;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * @version: V0.3
 * @author: 吴嘉鑫
 * @className: Message
 * @packageName: com.example.demo.Entity
 * @description: 这是信息类，用来收集发布的招聘求职信息。
 * @data: 2021-07-2019
 **/

@JsonIgnoreProperties({"hibernateLazyInitializer","handler"})//是因为查询到的对象是null值没有获取到，无法反序列化为json 返回到前台
@Entity
@Table(name="message")
public class Message implements Comparable<Message>{
	
	/**
	 * 讯息ID
	 */
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer mesID;
	
	
	/**
	 * 发布用户类型
	 */
	private boolean userType;//0代表员工的求职，1代表HR招聘
	
	/**
	 * 发布用户的用户名
	 */
	private String userName;
	
	/**
	 * 发布用户期望获得/能够支付的年薪
	 */
	private Integer salary;
	
	/**
	 * 发布用户自称/需要的职位
	 */
	private String position;
	
	/**
	 * 发布正文
	 */
	private String text;
	
	/**
	 * 发布时间
	 */
	@CreationTimestamp
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date created;//构建时间




	public Integer getMesID() {
		return mesID;
	}



	public void setMesID(Integer mesID) {
		this.mesID = mesID;
	}



	public boolean isUserType() {
		return userType;
	}



	public void setUserType(boolean userType) {
		this.userType = userType;
	}



	public String getUserName() {
		return userName;
	}



	public void setUserName(String userName) {
		this.userName = userName;
	}



	public String getText() {
		return text;
	}



	public void setText(String text) {
		this.text = text;
	}



	public Date getCreated() {
		return created;
	}



	public void setCreated(Date created) {
		this.created = created;
	}


	@Override
	public String toString() {
		return "Message [mesID=" + mesID + ", userType=" + userType + ", userName=" + userName + ", salary=" + salary
				+ ", position=" + position + ", text=" + text + ", created=" + created + "]";
	}



	@Override
	public int compareTo(Message mes) {
	return this.created.before(mes.created)?1:-1;
	}

	public String getPosition() {
		return position;
	}



	public void setPosition(String position) {
		this.position = position;
	}



	public Integer getSalary() {
		return salary;
	}



	public void setSalary(Integer salary) {
		this.salary = salary;
	}	

}
